﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide.ui {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import com.greensock.*;

    public class GuideArrow {

        public static const ARROW_UP:int = 1;
        public static const ARROW_RIGHT:int = 2;
        public static const ARROW_DOWN:int = 3;
        public static const ARROW_LEFT:int = 4;

        private var m_direction:int;
        private var m_useRotate:Boolean;
        private var m_loader:Loader;
        private var m_asset:DisplayObject;
        private var m_active:Boolean = true;
        private var m_tweenTime:Number = 0.3;
        protected var m_aboveHud:Boolean;
        protected var m_locX:Number;
        protected var m_locY:Number;
        protected var m_width:Number;
        protected var m_height:Number;

        public function GuideArrow(_arg1:String, _arg2:Number, _arg3:Number, _arg4:Number=0, _arg5:Number=0, _arg6:int=4, _arg7:Boolean=true, _arg8:Boolean=false){
            this.m_locX = _arg2;
            this.m_locY = _arg3;
            this.m_width = _arg4;
            this.m_height = _arg5;
            this.m_direction = _arg6;
            this.m_useRotate = _arg7;
            this.m_aboveHud = _arg8;
            this.m_loader = LoadingManager.load(_arg1, this.onLoaderEvent, LoadingManager.PRIORITY_HIGH);
        }
        public function getAsset():DisplayObject{
            return (this.m_asset);
        }
        public function release():void{
            this.m_active = false;
            if (this.m_asset != null){
                TweenLite.to(this.m_asset, this.m_tweenTime, {
                    alpha:0,
                    onComplete:this.onFinishRemoveMask
                });
            };
        }
        private function onFinishRemoveMask():void{
            Global.ui.removeChild(this.m_asset);
        }
        private function onLoaderEvent(_arg1:Event):void{
            if (((((this.m_loader) && (this.m_loader.content))) && (this.m_active))){
                this.m_asset = this.m_loader.content;
                if (this.m_width != 0){
                    this.m_asset.width = this.m_width;
                };
                if (this.m_height != 0){
                    this.m_asset.height = this.m_height;
                };
                if (((this.m_useRotate) && (!((this.m_direction == ARROW_RIGHT))))){
                    switch (this.m_direction){
                        case ARROW_LEFT:
                            this.m_asset.rotation = 180;
                            break;
                        case ARROW_DOWN:
                            this.m_asset.rotation = 90;
                            break;
                        case ARROW_UP:
                            this.m_asset.rotation = 270;
                            break;
                    };
                };
                this.updatePosition();
                this.m_asset.visible = true;
                this.m_asset.scaleX = 1;
                this.m_asset.scaleY = 1;
                if (this.m_aboveHud){
                    Global.ui.addChild(this.m_asset);
                    Global.ui.setChildIndex(this.m_asset, (Global.ui.numChildren - 1));
                } else {
                    Global.ui.addChildAt(this.m_asset, 0);
                };
            };
        }
        public function setPosition(_arg1:Number, _arg2:Number):void{
            this.m_locX = _arg1;
            this.m_locY = _arg2;
            this.updatePosition();
        }
        private function updatePosition():void{
            if (!this.m_asset){
                return;
            };
            switch (this.m_direction){
                case ARROW_LEFT:
                    this.m_asset.x = this.m_locX;
                    this.m_asset.y = (this.m_locY + (this.m_asset.height / 2));
                    break;
                case ARROW_RIGHT:
                    this.m_asset.x = this.m_locX;
                    this.m_asset.y = (this.m_locY - (this.m_asset.height / 2));
                    break;
                case ARROW_DOWN:
                    this.m_asset.x = (this.m_locX + (this.m_asset.width / 2));
                    this.m_asset.y = this.m_locY;
                    break;
                case ARROW_UP:
                    this.m_asset.x = (this.m_locX - (this.m_asset.width / 2));
                    this.m_asset.y = this.m_locY;
                    break;
            };
        }
        public function hasLoaded():Boolean{
            return ((this.m_loader.contentLoaderInfo.bytesLoaded >= this.m_loader.contentLoaderInfo.bytesTotal));
        }

    }
}//package Modules.guide.ui 
